class DefaultConfig(object):
    """
    Flask默认配置
    """
    # redis 哨兵
    REDIS_SENTINELS = [
        ('127.0.0.1', '26380'),  # 哨兵ip+端口
        ('127.0.0.1', '26381'),
        ('127.0.0.1', '26382'),
    ]
    REDIS_SENTINEL_SERVICE_NAME = 'mymaster'  # 主数据库别名

    # redis 集群
    REDIS_CLUSTER = [
        {'host': '127.0.0.1', 'port': '7000'},
        {'host': '127.0.0.1', 'port': '7001'},
        {'host': '127.0.0.1', 'port': '7002'},
    ]

    # 日志
    LOGGING_LEVEL = 'DEBUG'  # 日志级别
    LOGGING_FILE_DIR = '/home/python/logs'  # 日志文件目录
    LOGGING_FILE_MAX_BYTES = 300 * 1024 * 1024  # 日志文件大小
    LOGGING_FILE_BACKUP = 10  # 日志文件数量
    PROPAGATE_EXCEPTIONS = True  # 设置为False, 则flask内置日志会写入文件, 但错误信息将不会显示到网页上

    # sqlalchemy
    SQLALCHEMY_BINDS = {
        "bj_m1": 'mysql://root:mysql@192.168.105.135:3306/toutiao',
        "bj_m2": 'mysql://root:mysql@192.168.105.135:3306/toutiao',
        "bj_s1": 'mysql://root:mysql@192.168.105.135:8306/toutiao',
        "bj_s2": 'mysql://root:mysql@192.168.105.135:8306/toutiao',
    }
    SQLALCHEMY_CLUSTER = {
        "masters": ["bj_m1", "bj_m2"],
        "slaves": ['bj_s2', 'bj_s2'],
        "default": 'bj_m1'
    }    # 数据库连接
    SQLALCHEMY_TRACK_MODIFICATIONS = False  # 追踪数据的修改信号
    SQLALCHEMY_ECHO = True  # 打印底层sql语句

    # Snowflake ID Worker 参数
    DATACENTER_ID = 0
    WORKER_ID = 0
    SEQUENCE = 0

    # JWT
    JWT_SECRET = 'TPmi4aLWRbyVq8zu9v82dWYW17/z+UvRnYTt4P6fAXA'  # 默认消息认证的秘钥
    JWT_EXPIRY_HOURS = 2  # 访问token的过期时间
    JWT_REFRESH_DAYS = 14  # 刷新token的过期时间

    # 七牛云
    QINIU_ACCESS_KEY = 'kJ8wVO7lmFGsdvtI5M7eQDEJ1eT3Vrygb4SmR00E'
    QINIU_SECRET_KEY = 'rGwHyAvnlLK7rU4htRpNYzpuz0OHJKzX2O1LWTNl'
    QINIU_BUCKET_NAME = 'sh26'
    QINIU_DOMAIN = 'http://puk2zync7.bkt.clouddn.com/'

    # rpc
    class RPC:
        RECOMMEND = '192.168.49.78:8888'
        CHATBOT = '172.17.0.59:9999'

    # 消息队列的连接地址
    RABBITMQ = 'amqp://guest:guest@192.168.105.128:5672'

    # elasticsearch集群服务器的地址
    ES = [
        '127.0.0.1:9200'
    ]


class TestingConfig(DefaultConfig):
    TESTING = True  # 如果进行单元测试, 建议设置为True, 一旦开启, 会停用所有flask内部的异常捕获(这样会精确定位到错误位置)